using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
namespace SS
{
	public class FrmRootCompany : Form
	{
		private IContainer components = null;
		private TextBox txtComWebsite;
		private Label label8;
		private TextBox txtComTax;
		private Label label7;
		private TextBox txtComEmail;
		private Label label6;
		private TextBox txtComFax;
		private Label label5;
		private TextBox txtComPhone;
		private Label label4;
		private TextBox txtComAddress;
		private Label label3;
		private TextBox txtComManager;
		private Label label2;
		private TextBox txtComName;
		private Label label1;
		private Button cmdClose;
		private Button cmdUpdate;
		private TextBox txtComDoctor;
		private Label label9;
		private TextBox txtBillDescription;
		private Label label10;
		private Func objFunc = new Func();
		private string strConnection = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(FrmRootCompany));
			this.cmdClose = new Button();
			this.cmdUpdate = new Button();
			this.txtComWebsite = new TextBox();
			this.label8 = new Label();
			this.txtComTax = new TextBox();
			this.label7 = new Label();
			this.txtComEmail = new TextBox();
			this.label6 = new Label();
			this.txtComFax = new TextBox();
			this.label5 = new Label();
			this.txtComPhone = new TextBox();
			this.label4 = new Label();
			this.txtComAddress = new TextBox();
			this.label3 = new Label();
			this.txtComManager = new TextBox();
			this.label2 = new Label();
			this.txtComName = new TextBox();
			this.label1 = new Label();
			this.txtComDoctor = new TextBox();
			this.label9 = new Label();
			this.txtBillDescription = new TextBox();
			this.label10 = new Label();
			base.SuspendLayout();
			this.cmdClose.BackColor = Color.FromArgb(192, 255, 255);
			this.cmdClose.Cursor = Cursors.Hand;
			this.cmdClose.FlatAppearance.BorderColor = Color.FromArgb(0, 192, 192);
			this.cmdClose.FlatStyle = FlatStyle.System;
			this.cmdClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
//			this.cmdClose.Image = (Image)componentResourceManager.GetObject("cmdClose.Image");
			this.cmdClose.ImageAlign = ContentAlignment.MiddleLeft;
//			this.cmdClose.ImeMode = ImeMode.NoControl;
			this.cmdClose.Location = new Point(434, 248);
			this.cmdClose.Name = "cmdClose";
			this.cmdClose.Size = new Size(90, 30);
			this.cmdClose.TabIndex = 23;
			this.cmdClose.Text = "Thoát [ESC]";
			this.cmdClose.UseVisualStyleBackColor = false;
			this.cmdClose.Click += new EventHandler(this.cmdClose_Click);
			this.cmdUpdate.BackColor = Color.FromArgb(192, 255, 255);
			this.cmdUpdate.Cursor = Cursors.Hand;
			this.cmdUpdate.FlatAppearance.BorderColor = Color.FromArgb(0, 192, 192);
			this.cmdUpdate.FlatStyle = FlatStyle.System;
			this.cmdUpdate.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
//			this.cmdUpdate.Image = (Image)componentResourceManager.GetObject("cmdUpdate.Image");
			this.cmdUpdate.ImageAlign = ContentAlignment.MiddleLeft;
//			this.cmdUpdate.ImeMode = ImeMode.NoControl;
			this.cmdUpdate.Location = new Point(342, 248);
			this.cmdUpdate.Name = "cmdUpdate";
			this.cmdUpdate.Size = new Size(90, 30);
			this.cmdUpdate.TabIndex = 22;
			this.cmdUpdate.Text = "Ghi nhận";
			this.cmdUpdate.UseVisualStyleBackColor = false;
			this.cmdUpdate.Click += new EventHandler(this.cmdUpdate_Click);
			this.txtComWebsite.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComWebsite.Location = new Point(152, 151);
			this.txtComWebsite.Name = "txtComWebsite";
			this.txtComWebsite.Size = new Size(372, 23);
			this.txtComWebsite.TabIndex = 7;
			this.label8.AutoSize = true;
			this.label8.BackColor = Color.Transparent;
			this.label8.Location = new Point(90, 155);
			this.label8.Name = "label8";
			this.label8.Size = new Size(58, 15);
			this.label8.TabIndex = 14;
			this.label8.Text = "Website :";
			this.txtComTax.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComTax.Location = new Point(152, 122);
			this.txtComTax.Name = "txtComTax";
			this.txtComTax.Size = new Size(140, 23);
			this.txtComTax.TabIndex = 5;
			this.label7.AutoSize = true;
			this.label7.BackColor = Color.Transparent;
			this.label7.Location = new Point(303, 127);
			this.label7.Name = "label7";
			this.label7.Size = new Size(45, 15);
			this.label7.TabIndex = 12;
			this.label7.Text = "Email :";
			this.txtComEmail.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComEmail.Location = new Point(351, 123);
			this.txtComEmail.Name = "txtComEmail";
			this.txtComEmail.Size = new Size(173, 23);
			this.txtComEmail.TabIndex = 6;
			this.label6.AutoSize = true;
			this.label6.BackColor = Color.Transparent;
			this.label6.Location = new Point(75, 127);
			this.label6.Name = "label6";
			this.label6.Size = new Size(73, 15);
			this.label6.TabIndex = 10;
			this.label6.Text = "Mã số thuế :";
			this.txtComFax.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComFax.Location = new Point(351, 95);
			this.txtComFax.Name = "txtComFax";
			this.txtComFax.Size = new Size(173, 23);
			this.txtComFax.TabIndex = 4;
			this.label5.AutoSize = true;
			this.label5.BackColor = Color.Transparent;
			this.label5.Location = new Point(298, 99);
			this.label5.Name = "label5";
			this.label5.Size = new Size(50, 15);
			this.label5.TabIndex = 8;
			this.label5.Text = "Số Fax :";
			this.txtComPhone.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComPhone.Location = new Point(152, 95);
			this.txtComPhone.Name = "txtComPhone";
			this.txtComPhone.Size = new Size(140, 23);
			this.txtComPhone.TabIndex = 3;
			this.label4.AutoSize = true;
			this.label4.BackColor = Color.Transparent;
			this.label4.Location = new Point(79, 99);
			this.label4.Name = "label4";
			this.label4.Size = new Size(69, 15);
			this.label4.TabIndex = 6;
			this.label4.Text = "Điện thoại :";
			this.txtComAddress.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComAddress.Location = new Point(152, 67);
			this.txtComAddress.Name = "txtComAddress";
			this.txtComAddress.Size = new Size(372, 23);
			this.txtComAddress.TabIndex = 2;
			this.label3.AutoSize = true;
			this.label3.BackColor = Color.Transparent;
			this.label3.Location = new Point(97, 71);
			this.label3.Name = "label3";
			this.label3.Size = new Size(51, 15);
			this.label3.TabIndex = 4;
			this.label3.Text = "Địa chỉ :";
			this.txtComManager.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComManager.Location = new Point(152, 39);
			this.txtComManager.Name = "txtComManager";
			this.txtComManager.Size = new Size(372, 23);
			this.txtComManager.TabIndex = 1;
			this.label2.AutoSize = true;
			this.label2.BackColor = Color.Transparent;
			this.label2.Location = new Point(53, 43);
			this.label2.Name = "label2";
			this.label2.Size = new Size(95, 15);
			this.label2.TabIndex = 2;
			this.label2.Text = "Người đại diện :";
			this.txtComName.CharacterCasing = CharacterCasing.Upper;
			this.txtComName.Font = new Font("Tahoma", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.txtComName.Location = new Point(152, 11);
			this.txtComName.Name = "txtComName";
			this.txtComName.Size = new Size(372, 23);
			this.txtComName.TabIndex = 0;
			this.label1.AutoSize = true;
			this.label1.BackColor = Color.Transparent;
			this.label1.Location = new Point(78, 15);
			this.label1.Name = "label1";
			this.label1.Size = new Size(70, 15);
			this.label1.TabIndex = 0;
			this.label1.Text = "Tên đơn vị :";
			this.txtComDoctor.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtComDoctor.Location = new Point(152, 179);
			this.txtComDoctor.Name = "txtComDoctor";
			this.txtComDoctor.Size = new Size(372, 23);
			this.txtComDoctor.TabIndex = 8;
			this.label9.AutoSize = true;
			this.label9.BackColor = Color.Transparent;
			this.label9.Location = new Point(83, 182);
			this.label9.Name = "label9";
			this.label9.Size = new Size(65, 15);
			this.label9.TabIndex = 24;
			this.label9.Text = "Phụ trách :";
			this.txtBillDescription.Font = new Font("Tahoma", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtBillDescription.Location = new Point(152, 207);
			this.txtBillDescription.Name = "txtBillDescription";
			this.txtBillDescription.Size = new Size(372, 23);
			this.txtBillDescription.TabIndex = 9;
			this.label10.AutoSize = true;
			this.label10.BackColor = Color.Transparent;
			this.label10.Location = new Point(7, 211);
			this.label10.Name = "label10";
			this.label10.Size = new Size(141, 15);
			this.label10.TabIndex = 26;
			this.label10.Text = "Tiêu đề dưới đơn thuốc :";
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(534, 288);
			base.Controls.Add(this.txtBillDescription);
			base.Controls.Add(this.label10);
			base.Controls.Add(this.txtComDoctor);
			base.Controls.Add(this.label9);
			base.Controls.Add(this.cmdClose);
			base.Controls.Add(this.cmdUpdate);
			base.Controls.Add(this.txtComName);
			base.Controls.Add(this.txtComWebsite);
			base.Controls.Add(this.label1);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.txtComTax);
			base.Controls.Add(this.txtComManager);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.txtComEmail);
			base.Controls.Add(this.txtComAddress);
			base.Controls.Add(this.label6);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.txtComFax);
			base.Controls.Add(this.txtComPhone);
			base.Controls.Add(this.label5);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Margin = new Padding(3, 4, 3, 4);
			base.MaximizeBox = false;
			this.MaximumSize = new Size(550, 322);
			base.MinimizeBox = false;
			this.MinimumSize = new Size(550, 322);
			base.Name = "FrmRootCompany";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = " .: Đơn vị sử dụng";
			base.Load += new EventHandler(this.FrmCompany_Load);
			base.KeyDown += new KeyEventHandler(this.FrmRootCompany_KeyDown);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public FrmRootCompany()
		{
			this.InitializeComponent();
		}
		private void cmdClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void FrmCompany_Load(object sender, EventArgs e)
		{
			try
			{
				Program.strConnectionString = this.objFunc.strConnectionString;
				Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = "SELECT * FROM [TabCompany] WHERE [ComID] = 'COM01'";
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					this.txtComName.Text = sqlDataReader["ComName"].ToString();
					this.txtComAddress.Text = sqlDataReader["ComAddress"].ToString();
					this.txtComManager.Text = sqlDataReader["ComManager"].ToString();
					this.txtComPhone.Text = sqlDataReader["ComPhone"].ToString();
					this.txtComFax.Text = sqlDataReader["ComFax"].ToString();
					this.txtComTax.Text = sqlDataReader["ComTax"].ToString();
					this.txtComEmail.Text = sqlDataReader["ComEmail"].ToString();
					this.txtComWebsite.Text = sqlDataReader["ComWebsite"].ToString();
					this.txtComDoctor.Text = sqlDataReader["ComDoctor"].ToString();
					this.txtBillDescription.Text = sqlDataReader["BillDescription"].ToString();
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
			}
			catch
			{
			}
		}
		private void cmdUpdate_Click(object sender, EventArgs e)
		{
			try
			{
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				SqlCommand sqlCommand = new SqlCommand("ActionOnTabCompany", sqlConnection);
				sqlCommand.CommandType = CommandType.StoredProcedure;
				sqlCommand.Parameters.Add("@ComID", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComName", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComManager", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComAddress", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComPhone", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComFax", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComEmail", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComTax", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComWebsite", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@ComDoctor", SqlDbType.NVarChar);
				sqlCommand.Parameters.Add("@BillDescription", SqlDbType.NVarChar);
				sqlCommand.Parameters["@ComID"].Value = "COM01";
				sqlCommand.Parameters["@ComName"].Value = this.txtComName.Text;
				sqlCommand.Parameters["@ComManager"].Value = this.txtComManager.Text;
				sqlCommand.Parameters["@ComAddress"].Value = this.txtComAddress.Text;
				sqlCommand.Parameters["@ComPhone"].Value = this.txtComPhone.Text;
				sqlCommand.Parameters["@ComFax"].Value = this.txtComFax.Text;
				sqlCommand.Parameters["@ComEmail"].Value = this.txtComEmail.Text;
				sqlCommand.Parameters["@ComTax"].Value = this.txtComTax.Text;
				sqlCommand.Parameters["@ComWebsite"].Value = this.txtComWebsite.Text;
				sqlCommand.Parameters["@ComDoctor"].Value = this.txtComDoctor.Text;
				sqlCommand.Parameters["@BillDescription"].Value = this.txtBillDescription.Text;
				sqlConnection.Open();
				sqlCommand.ExecuteNonQuery();
				sqlConnection.Close();
				sqlConnection.Dispose();
				base.Close();
			}
			catch
			{
			}
		}
		private void FrmRootCompany_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
	}
}
